.class public Lcom/waiqin365/lightapp/view/MaskImage;
.super Landroid/widget/ImageView;


# instance fields
.field public a:Landroid/graphics/Paint;

.field private b:Landroid/graphics/drawable/Drawable;

.field private c:Landroid/graphics/drawable/Drawable;

.field private d:Landroid/graphics/Bitmap;

.field private e:Landroid/graphics/PorterDuffXfermode;

.field private f:Landroid/graphics/PorterDuffXfermode;

.field private g:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 2

    const/4 v0, 0x0

    invoke-direct {p0, p1}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->c:Landroid/graphics/drawable/Drawable;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    new-instance v0, Landroid/graphics/Paint;

    const/4 v1, 0x1

    invoke-direct {v0, v1}, Landroid/graphics/Paint;-><init>(I)V

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 1

    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, v0}, Lcom/waiqin365/lightapp/view/MaskImage;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 3

    const/4 v0, 0x0

    const/4 v2, -0x1

    invoke-direct {p0, p1, p2, p3}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->c:Landroid/graphics/drawable/Drawable;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    new-instance v0, Landroid/graphics/Paint;

    const/4 v1, 0x1

    invoke-direct {v0, v1}, Landroid/graphics/Paint;-><init>(I)V

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    sget-object v0, Lcom/fiberhome/gaea/client/base/g;->MaskImage:[I

    invoke-virtual {p1, p2, v0}, Landroid/content/Context;->obtainStyledAttributes(Landroid/util/AttributeSet;[I)Landroid/content/res/TypedArray;

    move-result-object v0

    const/4 v1, 0x0

    invoke-virtual {v0, v1, v2}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result v1

    if-eq v1, v2, :cond_0

    invoke-virtual {p0, v1}, Lcom/waiqin365/lightapp/view/MaskImage;->setMaskImg(I)V

    :cond_0
    const/4 v1, 0x2

    invoke-virtual {v0, v1, v2}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result v1

    if-eq v1, v2, :cond_1

    invoke-virtual {p0, v1}, Lcom/waiqin365/lightapp/view/MaskImage;->setRecoverDrawable(I)V

    :cond_1
    invoke-virtual {v0}, Landroid/content/res/TypedArray;->recycle()V

    return-void
.end method

.method private a(Landroid/graphics/Canvas;)V
    .locals 3

    const/4 v2, 0x0

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    const/4 v1, 0x0

    invoke-virtual {p1, v0, v2, v2, v1}, Landroid/graphics/Canvas;->drawBitmap(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V

    return-void
.end method

.method private a(Landroid/graphics/Canvas;Landroid/graphics/Bitmap;)V
    .locals 7

    const/4 v2, 0x0

    invoke-virtual {p2}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v0

    int-to-float v3, v0

    invoke-virtual {p2}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v0

    int-to-float v4, v0

    int-to-float v1, v2

    int-to-float v2, v2

    const/4 v5, 0x0

    const/16 v6, 0x1f

    move-object v0, p1

    invoke-virtual/range {v0 .. v6}, Landroid/graphics/Canvas;->saveLayer(FFFFLandroid/graphics/Paint;I)I

    move-result v0

    invoke-direct {p0, p1, p2}, Lcom/waiqin365/lightapp/view/MaskImage;->b(Landroid/graphics/Canvas;Landroid/graphics/Bitmap;)V

    invoke-virtual {p1, v0}, Landroid/graphics/Canvas;->restoreToCount(I)V

    return-void
.end method

.method private b(Landroid/graphics/Canvas;)V
    .locals 5

    const/4 v4, 0x0

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    new-instance v1, Landroid/graphics/Rect;

    iget-object v2, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v2}, Landroid/graphics/drawable/Drawable;->getMinimumWidth()I

    move-result v2

    iget-object v3, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v3}, Landroid/graphics/drawable/Drawable;->getMinimumWidth()I

    move-result v3

    invoke-direct {v1, v4, v4, v2, v3}, Landroid/graphics/Rect;-><init>(IIII)V

    invoke-virtual {v0, v1}, Landroid/graphics/drawable/Drawable;->setBounds(Landroid/graphics/Rect;)V

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v0, p1}, Landroid/graphics/drawable/Drawable;->draw(Landroid/graphics/Canvas;)V

    return-void
.end method

.method private b(Landroid/graphics/Canvas;Landroid/graphics/Bitmap;)V
    .locals 6

    const/4 v2, 0x0

    const/16 v5, 0x28

    const/4 v4, 0x0

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    if-eqz v0, :cond_4

    invoke-direct {p0, p1}, Lcom/waiqin365/lightapp/view/MaskImage;->a(Landroid/graphics/Canvas;)V

    :goto_0
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->e:Landroid/graphics/PorterDuffXfermode;

    if-nez v0, :cond_0

    new-instance v0, Landroid/graphics/PorterDuffXfermode;

    sget-object v1, Landroid/graphics/PorterDuff$Mode;->SRC_ATOP:Landroid/graphics/PorterDuff$Mode;

    invoke-direct {v0, v1}, Landroid/graphics/PorterDuffXfermode;-><init>(Landroid/graphics/PorterDuff$Mode;)V

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->e:Landroid/graphics/PorterDuffXfermode;

    :cond_0
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->f:Landroid/graphics/PorterDuffXfermode;

    if-nez v0, :cond_1

    new-instance v0, Landroid/graphics/PorterDuffXfermode;

    sget-object v1, Landroid/graphics/PorterDuff$Mode;->MULTIPLY:Landroid/graphics/PorterDuff$Mode;

    invoke-direct {v0, v1}, Landroid/graphics/PorterDuffXfermode;-><init>(Landroid/graphics/PorterDuff$Mode;)V

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->f:Landroid/graphics/PorterDuffXfermode;

    :cond_1
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    const/16 v1, 0xff

    invoke-virtual {v0, v1, v4, v4, v4}, Landroid/graphics/Paint;->setARGB(IIII)V

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    iget-object v1, p0, Lcom/waiqin365/lightapp/view/MaskImage;->e:Landroid/graphics/PorterDuffXfermode;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setXfermode(Landroid/graphics/Xfermode;)Landroid/graphics/Xfermode;

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    invoke-virtual {p1, p2, v2, v2, v0}, Landroid/graphics/Canvas;->drawBitmap(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->c:Landroid/graphics/drawable/Drawable;

    if-eqz v0, :cond_2

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->c:Landroid/graphics/drawable/Drawable;

    check-cast v0, Landroid/graphics/drawable/NinePatchDrawable;

    new-instance v1, Landroid/graphics/Rect;

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getWidth()I

    move-result v2

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getHeight()I

    move-result v3

    invoke-direct {v1, v4, v4, v2, v3}, Landroid/graphics/Rect;-><init>(IIII)V

    invoke-virtual {v0, v1}, Landroid/graphics/drawable/NinePatchDrawable;->setBounds(Landroid/graphics/Rect;)V

    invoke-virtual {v0, p1}, Landroid/graphics/drawable/NinePatchDrawable;->draw(Landroid/graphics/Canvas;)V

    :cond_2
    iget-boolean v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->g:Z

    if-eqz v0, :cond_3

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    const/16 v1, 0x96

    invoke-virtual {v0, v1, v5, v5, v5}, Landroid/graphics/Paint;->setARGB(IIII)V

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    iget-object v1, p0, Lcom/waiqin365/lightapp/view/MaskImage;->f:Landroid/graphics/PorterDuffXfermode;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setXfermode(Landroid/graphics/Xfermode;)Landroid/graphics/Xfermode;

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->a:Landroid/graphics/Paint;

    invoke-virtual {p1, v0}, Landroid/graphics/Canvas;->drawPaint(Landroid/graphics/Paint;)V

    :cond_3
    return-void

    :cond_4
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    if-eqz v0, :cond_6

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    instance-of v0, v0, Landroid/graphics/drawable/NinePatchDrawable;

    if-eqz v0, :cond_5

    invoke-direct {p0, p1}, Lcom/waiqin365/lightapp/view/MaskImage;->c(Landroid/graphics/Canvas;)V

    goto :goto_0

    :cond_5
    invoke-direct {p0, p1}, Lcom/waiqin365/lightapp/view/MaskImage;->b(Landroid/graphics/Canvas;)V

    goto :goto_0

    :cond_6
    const-string/jumbo v0, "MaskImage"

    const-string/jumbo v1, "socurce must be .9 or bitmap or drawble"

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0
.end method

.method private c(Landroid/graphics/Canvas;)V
    .locals 5

    const/4 v4, 0x0

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    check-cast v0, Landroid/graphics/drawable/NinePatchDrawable;

    new-instance v1, Landroid/graphics/Rect;

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getWidth()I

    move-result v2

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getHeight()I

    move-result v3

    invoke-direct {v1, v4, v4, v2, v3}, Landroid/graphics/Rect;-><init>(IIII)V

    invoke-virtual {v0, v1}, Landroid/graphics/drawable/NinePatchDrawable;->setBounds(Landroid/graphics/Rect;)V

    invoke-virtual {v0, p1}, Landroid/graphics/drawable/NinePatchDrawable;->draw(Landroid/graphics/Canvas;)V

    return-void
.end method


# virtual methods
.method protected onDraw(Landroid/graphics/Canvas;)V
    .locals 2

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getDrawable()Landroid/graphics/drawable/Drawable;

    move-result-object v0

    if-eqz v0, :cond_0

    instance-of v1, v0, Landroid/graphics/drawable/BitmapDrawable;

    if-eqz v1, :cond_0

    check-cast v0, Landroid/graphics/drawable/BitmapDrawable;

    check-cast v0, Landroid/graphics/drawable/BitmapDrawable;

    invoke-virtual {v0}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object v0

    if-eqz v0, :cond_0

    invoke-direct {p0, p1, v0}, Lcom/waiqin365/lightapp/view/MaskImage;->a(Landroid/graphics/Canvas;Landroid/graphics/Bitmap;)V

    :cond_0
    return-void
.end method

.method protected onMeasure(II)V
    .locals 3

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    if-eqz v0, :cond_1

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    instance-of v0, v0, Landroid/graphics/drawable/NinePatchDrawable;

    if-eqz v0, :cond_0

    invoke-super {p0, p1, p2}, Landroid/widget/ImageView;->onMeasure(II)V

    :goto_0
    return-void

    :cond_0
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v0}, Landroid/graphics/drawable/Drawable;->getMinimumWidth()I

    move-result v0

    iget-object v1, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v1}, Landroid/graphics/drawable/Drawable;->getMinimumHeight()I

    move-result v1

    invoke-virtual {p0, v0, v1}, Lcom/waiqin365/lightapp/view/MaskImage;->setMeasuredDimension(II)V

    goto :goto_0

    :cond_1
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    if-eqz v0, :cond_2

    const-string/jumbo v0, "onMeasure"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v2, "maskBitmap|||||W"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v2, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    invoke-virtual {v2}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string/jumbo v2, "   H"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v2, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    invoke-virtual {v2}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    invoke-virtual {v0}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v0

    iget-object v1, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    invoke-virtual {v1}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v1

    invoke-virtual {p0, v0, v1}, Lcom/waiqin365/lightapp/view/MaskImage;->setMeasuredDimension(II)V

    goto :goto_0

    :cond_2
    const-string/jumbo v0, "onMeasure"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v2, "else|+++++W"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string/jumbo v2, "   H"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    invoke-super {p0, p1, p2}, Landroid/widget/ImageView;->onMeasure(II)V

    goto :goto_0
.end method

.method public setCover(Z)V
    .locals 0

    iput-boolean p1, p0, Lcom/waiqin365/lightapp/view/MaskImage;->g:Z

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->invalidate()V

    return-void
.end method

.method public setMaskImg(I)V
    .locals 2

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    invoke-virtual {v0, p1}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->b:Landroid/graphics/drawable/Drawable;

    if-nez v0, :cond_0

    new-instance v0, Ljava/lang/RuntimeException;

    const-string/jumbo v1, "resid not find ,this resid is error"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    return-void
.end method

.method public setMaskImg(Landroid/graphics/Bitmap;)V
    .locals 2

    if-nez p1, :cond_0

    new-instance v0, Ljava/lang/RuntimeException;

    const-string/jumbo v1, "this mask bitmap can\'t null"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    iput-object p1, p0, Lcom/waiqin365/lightapp/view/MaskImage;->d:Landroid/graphics/Bitmap;

    return-void
.end method

.method public setRecoverDrawable(I)V
    .locals 2

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/MaskImage;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    invoke-virtual {v0, p1}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->c:Landroid/graphics/drawable/Drawable;

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/MaskImage;->c:Landroid/graphics/drawable/Drawable;

    if-nez v0, :cond_0

    new-instance v0, Ljava/lang/RuntimeException;

    const-string/jumbo v1, "resid not find ,this resid is error"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    return-void
.end method
